package com.yida.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.yida.common.core.domain.R;
import com.yida.common.core.utils.poi.ExcelUtil;
import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.common.log.annotation.Log;
import com.yida.common.log.enums.BusinessType;
import com.yida.common.security.annotation.InnerAuth;
import com.yida.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yida.system.api.domain.EsbRequestLog;
import com.yida.system.service.IEsbRequestLogService;

/**
 * 企业总线请求日志Controller
 * 
 * @author ruoyi
 * @date 2023-04-13
 */
@RestController
@RequestMapping("/system/esb/request/log")
@Api(tags = "企业总线请求日志")
public class EsbRequestLogController extends BaseController
{
    @Autowired
    private IEsbRequestLogService esbRequestLogService;

    /**
     * 查询企业总线请求日志列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "分页查询",response = EsbRequestLog.class)
    @RequiresPermissions("system:esb:request:list")
    public TableDataInfo list(EsbRequestLog esbRequestLog)
    {
        startPage();
        List<EsbRequestLog> list = esbRequestLogService.selectEsbRequestLogList(esbRequestLog);
        return getDataTable(list);
    }

    /**
     * 导出企业总线请求日志列表
     */
    @Log(title = "企业总线请求日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出日志")
    @RequiresPermissions("system:esb:request:export")
    public void export(HttpServletResponse response, EsbRequestLog esbRequestLog)
    {
        List<EsbRequestLog> list = esbRequestLogService.selectEsbRequestLogList(esbRequestLog);
        ExcelUtil<EsbRequestLog> util = new ExcelUtil<EsbRequestLog>(EsbRequestLog.class);
        util.exportExcel(response, list, "企业总线请求日志数据");
    }

    /**
     * 获取企业总线请求日志详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "详情",response = EsbRequestLog.class)
    @RequiresPermissions("system:esb:request:list")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(esbRequestLogService.selectEsbRequestLogById(id));
    }

    /**
     * 新增企业总线请求日志
     */
    @Log(title = "企业总线请求日志", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增")
    @RequiresPermissions("system:esb:request:save")
    public AjaxResult add(@RequestBody EsbRequestLog esbRequestLog)
    {
        return toAjax(esbRequestLogService.insertEsbRequestLog(esbRequestLog));
    }

    /**
     * 修改企业总线请求日志
     */
    @Log(title = "企业总线请求日志", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改")
    @RequiresPermissions("system:esb:request:edit")
    public AjaxResult edit(@RequestBody EsbRequestLog esbRequestLog)
    {
        return toAjax(esbRequestLogService.updateEsbRequestLog(esbRequestLog));
    }

    /**
     * 删除企业总线请求日志
     */
    @Log(title = "企业总线请求日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除")
    @RequiresPermissions("system:esb:request:delete")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(esbRequestLogService.deleteEsbRequestLogByIds(ids));
    }

    /**
     * 新增企业总线请求日志
     */
    @InnerAuth
    @Log(title = "企业总线请求日志", businessType = BusinessType.INSERT)
    @PostMapping("/inner/save")
    public R<Integer> innerSave(@RequestBody EsbRequestLog esbRequestLog)
    {
        return R.ok(esbRequestLogService.insertEsbRequestLog(esbRequestLog));
    }
}
